/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package extension.poker.zone;

import com.smartfoxserver.v2.entities.Room;
import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.extensions.BaseClientRequestHandler;
import extension.game.poker.PokerFlag;
import java.util.List;
import log.Debug;

/**
 *
 * @author daz
 */
public class TableInfoHandler extends BaseClientRequestHandler {

    @Override
    public void handleClientRequest(User user, ISFSObject params) {
        String roomName = params.getUtfString(Flag.ROOM_NAME);
        String groupName = params.getUtfString(Flag.GROUP_NAME);
        Debug.d("hand table info request ");
        Debug.d(params.getDump());
        user.setProperty(Flag.GROUP_NAME, groupName);
        PokerZoneExtension ext = (PokerZoneExtension) getParentExtension();
        List<Room> listRooms = ext.getParentZone().getRoomListFromGroup(groupName);
        for (Room r : listRooms) {
            if (roomName.equals(r.getName())) {
                Debug.d("player int room:" + r.getProperty(PokerFlag.ROOM_PLAYER_NAME));
                ext.getResponse().sendTableInfo(roomName, (List<String>) r.getProperty(PokerFlag.ROOM_PLAYER_NAME),
                        (List<Integer>) r.getProperty(PokerFlag.ROOM_PLAYER_POS), user);
                break;
            }
        }

    }
}
